package io.geekidea.boot.config.baiwang;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 百望相关配置信息封装类
 * 提供静态方法获取配置值，方便其他类调用
 */
@Component
public class BaiwangConfig {
    @Value("${baiwang.url}")
    private String urlValue;

    @Value("${baiwang.appkey}")
    private String appKeyValue;

    @Value("${baiwang.userName}")
    private String userNameValue;

    @Value("${baiwang.password}")
    private String passwordValue;

    @Value("${baiwang.app_secret}")
    private String appSecretValue;

    @Value("${baiwang.salt_value}")
    private String userSaltValue;

    private static String url;
    private static String appKey;
    private static String userName;
    private static String password;
    private static String appSecret;
    private static String userSalt;

    /**
     * 初始化方法，在Spring加载完配置后执行
     * 将实例变量的值赋值给静态变量
     */
    @PostConstruct
    public void init() {
        url = this.urlValue;
        appKey = this.appKeyValue;
        userName = this.userNameValue;
        password = this.passwordValue;
        appSecret = this.appSecretValue;
        userSalt = this.userSaltValue;
    }

    public static String getUrl() {
        return url;
    }

    public static String getAppKey() {
        return appKey;
    }

    public static String getUserName() {
        return userName;
    }

    public static String getPassword() {
        return password;
    }

    public static String getAppSecret() {
        return appSecret;
    }

    public static String getUserSalt() {
        return userSalt;
    }
}
